% callback routine load_default_values
% reads default parameters from file
% and fills them into the parameter space

% def_file=['*.dat'];
[FILENAME, PATHNAME] = uigetfile('*.dat', 'File with default values');
fname=[PATHNAME FILENAME];
[fid1,message]=fopen(fname,'r');

if fid1==-1
   error('File %s could not be opened',fname);
end;

HR=str2num(fscanf(fid1,'HR: %s\n',1));						% heart period = duration 1 cycle
EmaxV=str2num(fscanf(fid1,'Emax_V: %s\n',1));			% Emax ventricle
TEmaxV=str2num(fscanf(fid1,'TEmax_V: %s\n',1));			% time Emax ventricle
EminV=str2num(fscanf(fid1,'Emin_V: %s\n',1));			% Emin ventricle
VdeadV=str2num(fscanf(fid1,'Vdead_V: %s\n',1));			% dead LV volume
Pvenous=str2num(fscanf(fid1,'Pvenous: %s\n',1));		% LA filling pressure
Rmvfwd=str2num(fscanf(fid1,'Rmvfwd: %s\n',1));			% forward mitral valve resistance
Raofwd=str2num(fscanf(fid1,'Raofwd: %s\n',1));			% forward aortic valve resistance
Rmvbwd=str2num(fscanf(fid1,'Rmvbwd: %s\n',1));			% backward mitral valve resistance
Raobwd=str2num(fscanf(fid1,'Raobwd: %s\n',1));			% backward aortic valve resistance
Z0=str2num(fscanf(fid1,'Z0: %s\n',1));						% characteristic impedance
L=str2num(fscanf(fid1,'L: %s\n',1));						% inertance	% if L = 0, use a 3-element WK model 
C=str2num(fscanf(fid1,'C: %s\n',1));						% compliance
R=str2num(fscanf(fid1,'R: %s\n',1));						% resistance
t_interval=str2num(fscanf(fid1,'dT: %s\n',1));			% time interval

% display default parameters and allow for changing them

HandleEditTextHR=findobj(gcf,'Tag','EditTextHR');
set(HandleEditTextHR,'String',num2str(HR));

HandleSliderHR=findobj(gcf,'Tag','SliderHR');
set(HandleSliderHR,'Value',HR);

HandleEditTextT_interval=findobj(gcf,'Tag','EditTextT_interval');
set(HandleEditTextT_interval,'String',num2str(t_interval));

HandleSliderT_interval=findobj(gcf,'Tag','SliderT_interval');
set(HandleSliderT_interval,'Value',t_interval);

HandleEditTextEmaxV=findobj(gcf,'Tag','EditTextEmaxV');
set(HandleEditTextEmaxV,'String',num2str(EmaxV));

HandleEditTextTEmaxV=findobj(gcf,'Tag','EditTextTEmaxV');
set(HandleEditTextTEmaxV,'String',num2str(TEmaxV));

HandleEditTextEminV=findobj(gcf,'Tag','EditTextEminV');
set(HandleEditTextEminV,'String',num2str(EminV));

HandleEditTextVdeadV=findobj(gcf,'Tag','EditTextVdeadV');
set(HandleEditTextVdeadV,'String',num2str(VdeadV));

HandleEditTextPvenous=findobj(gcf,'Tag','EditTextPvenous');
set(HandleEditTextPvenous,'String',num2str(Pvenous));

HandleSliderPvenous=findobj(gcf,'Tag','SliderPvenous');
set(HandleSliderPvenous,'Value',Pvenous);

HandleEditTextZ0=findobj(gcf,'Tag','EditTextZ0');
set(HandleEditTextZ0,'String',num2str(Z0));

HandleEditTextL=findobj(gcf,'Tag','EditTextL');
set(HandleEditTextL,'String',num2str(L));

HandleEditTextC=findobj(gcf,'Tag','EditTextC');
set(HandleEditTextC,'String',num2str(C));

HandleEditTextR=findobj(gcf,'Tag','EditTextR');
set(HandleEditTextR,'String',num2str(R));

HandleEditTextRmv=findobj(gcf,'Tag','EditTextRmv');
set(HandleEditTextRmv,'String',num2str(Rmvfwd));

HandleEditTextRao=findobj(gcf,'Tag','EditTextRao');
set(HandleEditTextRao,'String',num2str(Raofwd));

HandleEditTextRmvbwd=findobj(gcf,'Tag','EditTextRmvbwd');
set(HandleEditTextRmvbwd,'String',num2str(Rmvbwd));

HandleEditTextRaobwd=findobj(gcf,'Tag','EditTextRaobwd');
set(HandleEditTextRaobwd,'String',num2str(Raobwd));

fclose(fid1);

